package cn.wolfcode.crm.service.impl;

import cn.wolfcode.crm.domain.BonusRecord;
import cn.wolfcode.crm.mapper.BonusRecordMapper;
import cn.wolfcode.crm.qo.QueryObject;
import cn.wolfcode.crm.service.IBonusRecordService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class BonusRecordServiceImpl implements IBonusRecordService{
	@Autowired
	private BonusRecordMapper bonusRecordMapper;
	@Override
	public void insert(BonusRecord bonusRecord) {
		bonusRecord.setInputTime(new Date());
		bonusRecordMapper.insert(bonusRecord);
	}

	/*@Override
	public void delete(Long id) {
		bonusRecordMapper.delete(id);
	}*/

	/*@Override
	public void update(BonusRecord bonusRecord) {
		bonusRecordMapper.update(bonusRecord);
	}*/

	@Override
	public BonusRecord select(Long id) {
		BonusRecord bonusRecord = bonusRecordMapper.select(id);
		return bonusRecord;
	}

	@Override
	public List<BonusRecord> list() {
		List<BonusRecord> list = bonusRecordMapper.list();
		return list;
	}

	public PageInfo<BonusRecord> query(QueryObject qo) {
		PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
        List<BonusRecord> bonusRecords = bonusRecordMapper.selectForList(qo);
        return new PageInfo<>(bonusRecords);
	}



}
